// Copyright (c) Microsoft Corporation.  All rights reserved.
#pragma once

//
// CContent class represents Windows SideShow Content sent by SideShow API to ISideShowDriver::OnAddContent handler
//

#define CONTENT_FLAGS_PARSED	1

//////#define _CONTENT_USE_ATLIMAGE

class CContent
{
public:
	CContent(CONTENT_ID contentId);
	~CContent();
	
	HRESULT SetData(const unsigned char* pData, DWORD cbData);
    HRESULT SetScfTree(CScfContentBase* pScfTree);

	HRESULT RenderContent(HDC hdc);
	HRESULT RenderContextMenu(HDC hdc);

	HRESULT OnDeviceEvent(CDevice::DeviceEvent DeviceEvent);
	VOID OnContentEnter();
	VOID OnContextMenuEnter();
	VOID OnApplicationExit();
	
	HRESULT DrawImage(HDC hdc, int x, int y, int cxDest, int cyDest);
	int GetImageWidth();
	int GetImageHeight();
	
	BOOL IsMenuContent()
	{
		return m_pParsedContent != NULL && m_pParsedContent->GetElementType() == SCF_MENU_ELEMENT;
	}

	BOOL HasImageReferenceOf(CONTENT_ID imgid);
	VOID InvalidateView();
	
private:
	// private methods
	HRESULT _ParseScf(CScfContentBase **ppParsedScf);
	HRESULT _CreateView(BOOL bContextMenu, HDC hdc);
	HRESULT _CreateBitmap();
	VOID _ClearParsedContentAndView();
	VOID _ClearBitmap();
	VOID _ClearRawData();
	
	VOID _NotifyUpdateDataToViewObject();
	
	// raw content data
	CONTENT_ID m_contentId;
	HGLOBAL m_hData;						// Raw Content
	DWORD m_cbData;
	DWORD m_dwFlags;
	
	// for scf content
	CScfContentBase* m_pParsedContent;		// Object model of SCF content (content or menu or dialog)
	CContentViewBase* m_pContentView;		// UI Object (content or menu or dialog view)
	CContextMenuView* m_pContextMenuView;	// context menu view

	// for image content
#ifdef _CONTENT_USE_ATLIMAGE
	CImage* m_pBitmap;
#else
	Gdiplus::Bitmap* m_pBitmap;				// GDI+ Bitmap
#endif
};

